﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace TheVerge.Base
{
    [DataContract]
    public class Comment
    {
        [DataMember(Name = "body")]
        public string Body { get; set; }
        [DataMember(Name = "created_on")]
        public DateTime CreatedOn { get; set; }

        [DataMember(Name = "id")]
        public long Id { get; set; }

        [IgnoreDataMember]
        public Comment Parent { get; set; }

        [DataMember(Name = "parent_id")]
        public long? ParentId { get; set; }

        [IgnoreDataMember]
        public IList<Comment> Replies { get; set; }

        [DataMember(Name = "title")]
        public string Title { get; set; }

        [DataMember(Name = "user_id")]
        public int UserId { get; set; }
        [DataMember(Name = "username")]
        public string UserName { get; set; }

        public Comment()
        {
            Replies = new List<Comment>();
        }

        [OnDeserialized]
        public void OnDeserialized(StreamingContext context)
        {
            Replies = new List<Comment>();
        }
    }

    [DataContract]
    public class Comments
    {
        [DataMember(Name = "comments")]
        public IList<CommentWrapper> AllComments { get; set; }
    }

    [DataContract]
    public class CommentWrapper
    {
        [DataMember(Name = "comment")]
        public Comment Comment { get; set; }
    }
}